class Solution {
    /*
        双指针
    */
    public int[] twoSum(int[] nums, int target) {
        int l = 0, r = nums.length - 1;
        while (l < r) {
            int sum = nums[l] + nums[r];
            if (sum < target)
                l++;
            else if (sum > target)
                r--;
            else
                return new int[]{nums[l], nums[r]};
        }
        return new int[]{};
    }
}